# flake8: NOQA

# -*- coding: UTF-8 -*-
"""
@Author  ：叶庭云
@公众号  ：AI庭云君
@CSDN    ：https://yetingyun.blog.csdn.net/
"""
from turtle import *
import turtle
import random

n = 100.0

speed(96)

turtle.setup(width=800, height=720)
# 用screensize设置的是画布大小及背景色
screensize(800, 800, "White")
left(90)
forward(3 * n)
color("red", "yellow")    # 五角星的颜色
begin_fill()
left(126)

for i in range(5):
    forward(n / 5)
    right(144)
    forward(n / 5)
    left(72)
end_fill()
right(126)

# 圣诞树颜色
color("#00CC00")
backward(n * 4.8)


def tree(d, s):
    if d <= 0:
        return
    forward(s)
    tree(d - 1, s * .8)
    right(120)
    tree(d - 3, s * .5)
    right(120)
    tree(d - 3, s * .5)
    right(120)
    backward(s)


tree(15, n)
backward(n / 2)

for i in range(200):
    a = 200 - 400 * random.random()
    b = 10 - 20 * random.random()
    up()
    forward(b)
    left(90)
    forward(a)
    down()
    if random.randint(0, 1) == 0:
        color('#FF0066')
    else:
        color('#FF6600')
    circle(2)
    up()
    backward(a)
    right(90)
    backward(b)

turtle.mainloop()
